package top.whk0710.baseAlg.sort;

public class InsertSort {

	public static void sort(int[] unsort) {
		for (int j = 1; j < unsort.length; j++) {
			int temp = unsort[j];
			int i = j - 1;
			while (i >= 0 && unsort[i] > temp) {
				unsort[i + 1] = unsort[i];
				i = i - 1;
			}
			unsort[i + 1] = temp;
		}
	}
	
	public static void main(String[] args){
		
		int[] abc = {2,1,4,3,5};
		sort(abc);
		for(int i=0;i<abc.length;i++)
			System.out.println(abc[i]);
	}
}
